/**
 * 文件名称：SpecificationsAction.java
 * 文件版权：ChinaParasol Technologies Co., Ltd. Copyright 2000-2020,  All rights reserved
 * 文件描述：<描述>
 * 创建作者：Administrator
 * 创建时间：Jan 6, 2013
 * 修改内容：<修改内容>
 */
package com.parasol.hcerp.service.specifications.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.parasol.hcerp.common.action.ParasolAction;
import com.parasol.hcerp.common.page.PageSepeHelper;
import com.parasol.hcerp.service.specifications.domain.SpecificationsBean;
import com.parasol.hcerp.service.specifications.service.SpecificationsService;

/**
 * 
 * @author  Administrator
 * @version V1.0, Jan 6, 2013
 */
public class SpecificationsAction extends ParasolAction
{

    /** 注释内容 */
    private static final long serialVersionUID = 5752991521437060768L;
    
    private SpecificationsService specificationsService = null;
    
    private SpecificationsBean specificationsBean = null;
    
    private PageSepeHelper pageSepeHelper = null;
    
    private String specificationsid = null;
    
    public PageSepeHelper getPageSepeHelper()
    {
        return pageSepeHelper;
    }

    public void setPageSepeHelper(PageSepeHelper pageSepeHelper)
    {
        this.pageSepeHelper = pageSepeHelper;
    }

    public SpecificationsService getSpecificationsService()
    {
        return specificationsService;
    }

    public void setSpecificationsService(SpecificationsService specificationsService)
    {
        this.specificationsService = specificationsService;
    }

    public SpecificationsBean getSpecificationsBean()
    {
        return specificationsBean;
    }

    public void setSpecificationsBean(SpecificationsBean specificationsBean)
    {
        this.specificationsBean = specificationsBean;
    }

    public String getSpecificationsid()
    {
        return specificationsid;
    }

    public void setSpecificationsid(String specificationsid)
    {
        this.specificationsid = specificationsid;
    }

    public String queryForList()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        List<SpecificationsBean> specificationsList = specificationsService.queryForList();
        request.setAttribute("specificationsList", specificationsList);
        return SUCCESS;
    }
    
    public String saveForJump()
    {
        super.clientCache();
        return SUCCESS;
    }
    
    public String saveForSpecifications()
    {
        super.clientCache();
        int result = specificationsService.queryForExist(specificationsBean);
        HttpServletRequest request = super.getRequest();
        if (result > 0)
        {
            request.setAttribute("errorMessage", "信息已经存在!");
            return ERROR;
        }
        
        specificationsService.saveForSpecifications(specificationsBean);
        List<SpecificationsBean> specificationsList = specificationsService.queryForList();
        request.setAttribute("specificationsList", specificationsList);
        return SUCCESS;
    }
    
    public String updateForJump()
    {
        super.clientCache();
        specificationsBean = specificationsService.queryForSpecifications(specificationsid);
        HttpServletRequest request = super.getRequest();
        request.setAttribute("specificationsBean", specificationsBean);
        return SUCCESS;
    }
    
    public String updateForSpecifications()
    {
        super.clientCache();
        int result = specificationsService.queryForExist(specificationsBean);
        HttpServletRequest request = super.getRequest();
        if (result > 0)
        {
            request.setAttribute("errorMessage", "信息已经存在!");
            return ERROR;
        }
        
        specificationsService.updateForSpecifications(specificationsBean);
        List<SpecificationsBean> specificationsList = specificationsService.queryForList();
        request.setAttribute("specificationsList", specificationsList);
        return SUCCESS;
    }
    
    public String deleteForSpecifications()
    {
        super.clientCache();
        specificationsService.deleteForSpecifications(specificationsid);
        
        HttpServletRequest request = super.getRequest();
        List<SpecificationsBean> specificationsList = specificationsService.queryForList();
        request.setAttribute("specificationsList", specificationsList);
        return SUCCESS;
    }
    
    public String showForSpecifications()
    {
        super.clientCache();
        specificationsBean = specificationsService.queryForSpecifications(specificationsid);
        HttpServletRequest request = super.getRequest();
        request.setAttribute("specificationsBean", specificationsBean);
        return SUCCESS;
    }
    
    public String selectSpecification()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        pageSepeHelper.isFirstLoad(request);
        List<SpecificationsBean> specificationsList = specificationsService.queryForList();
        request.setAttribute("specificationsList", specificationsList);
        return SUCCESS;
    }
    
}
